<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />

    <style>
        h3 {
            line-height: 40px;
        }

        #notice-1 {
            color: #fff;
            display: inline-block;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            border: 1px solid red;
            text-align: center;
            line-height: 20px;
            background-color: red;
        }
    </style>
</head>
<div id="nav-2" style="padding:10px 20px;background-color:#fff8d5;margin-top:30px;">
    <h3>若您还没有实名认证，请您<span style="color:red">实名认证</span></h3>
    <h3><span id="notice-1">!</span> 注意，实名认证后不可修改！ 采用联网认证！</h3>
</div>
<div style="margin-top:40px;background-color:#fff;padding:20px;">
    <div style="padding:0 10px">
        <ul class="aui-list aui-form-list" style="border:1px solid #ccc">
            <li class="aui-list-item">
                <div class="aui-list-item-inner" style="">
                    <div class="aui-list-item-label-icon">
                        真实姓名：
                    </div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请输入真实姓名" id="name">
                    </div>
                </div>
            </li>


        </ul>
    </div>
    <div style="padding:0 10px;margin-top:40px">
        <ul class="aui-list aui-form-list" style="border:1px solid #ccc">
            <li class="aui-list-item">
                <div class="aui-list-item-inner" style="">
                    <div class="aui-list-item-label-icon">
                        身份证号：
                    </div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请输入身份证号" id="number">
                    </div>
                </div>
            </li>
        </ul>
    </div>
</div>


<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="./js/interface_ajax.js"></script>
<script type="text/javascript">
    apiready = function() {
        GetRealName();

    };

    function fnSetValToWin() {
        var jsfun = 'setHeaderInfo("fav","收藏");';
        api.execScript({
            name: 'real_name', //winName//窗口名称
            script: jsfun
        });
    }


    function GetRealName() {

        var userInfo = $api.getStorage('userInfo');
        //获取数据app中存入的数据然后分配到模板中；
        var random = userInfo.random;
        var userid = userInfo.userid;
        api.ajax({
            url: SITE_URL + 'index.php?m=api&c=appnew&a=name_attesta1',
            method: 'post',
            data: {
                values: {
                    userid: userid,
                    random: random,
                },

            }
        }, function(ret, err) {
            if (ret.status == 1) {
                $("#name").val(ret.data.name);
                $("#number").val(ret.data.id_number);
            } else {
                alert(ret.msg);
            }
            //  alert(JSON.stringify(ret));
        });

    }

    function fnTryGoods() {
        //判断用户是否登录
        var is_login = $api.getStorage("userInfo");
        if (is_login) {
            var is_zhifubao_bind = false;
            if (is_zhifubao_bind) {

            } else {
                api.confirm({
                    title: '提示：',
                    msg: '请绑定淘宝账号，点击确定，马上去绑定！',
                    buttons: ['确定', '取消']
                }, function(ret, err) {

                    var index = ret.buttonIndex;
                    if (index == 1) {
                        //alert('我是支付宝页面');
                        api.openWin({
                            name: 'taobao_bind',
                            url: './taobao_bind.html',
                            pageParam: {
                                name: 'test' //给登录页面传递参数
                            }
                        });
                    }
                });
            }
            //发送一个ajax请求到接口，查看是否进行了支付宝验证；
            // api.ajax({
            //     url: SITE_URL+'index.php?m=api&c=appnew&a=goods_show&goods_id=' + goodId,
            //     method: 'get',
            // }, function(ret, err) {
            //     if (ret) {
            //       //如果可以请求接口成立
            //
            //
            //     } else {
            //         alert(JSON.stringify(err));
            //     }
            // });
            //如果没有绑定支付宝就弹出一个页面

        } else {
            api.confirm({
                title: '提示：',
                msg: '请先登录app',
                buttons: ['确定', '取消']
            }, function(ret, err) {

                var index = ret.buttonIndex;
                if (index == 1) {
                    api.openWin({
                        name: 'login',
                        url: './login.html',
                        pageParam: {
                            name: 'test' //给登录页面传递参数
                        }
                    });
                }
            });

        }
    }

    function initEventListenner() {

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.confirm({
                title: '提示',
                msg: '是否退出应用',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                if (ret.buttonIndex == 1) {
                    api.closeWidget({
                        silent: true
                    });
                }
            });
        });
    };

    function fnSubmitRealNameVal() {
        var userInfo = $api.getStorage('userInfo');
        //获取数据app中存入的数据然后分配到模板中；
        var random = userInfo.random;
        var userid = userInfo.userid;
        //获取需要的参数
        var name = $("#name").val();
        var number = $("#number").val();
        api.ajax({
            url: SITE_URL + 'index.php?m=api&c=appnew&a=name_attesta_alter',
            method: 'POST',
            data: {
                values: {
                    "name": name,
                    "userid": userid,
                    "random": random,
                    "number": number,
                }
            }
        }, function(ret, err) {
            //alert(JSON.stringify(ret));
            //弹出对话框
            // alert(ret.msg);
            // //跳转
            if (ret.status == 1) {

                api.closeWin();
                var jsfun = 'fnGetUserInfo();';
                api.execScript({
                    name: 'person_center',
                    frameName: 'person_center_frame',
                    script: jsfun
                });
                // api.openWin({
                //     name: 'person_center',
                //     url: './person_center.html',
                //     pageParam: {
                //         name: 'test'
                //     }
                // });
            } else {
                alert(ret.msg);
            }

        });
    }
</script>

</html>
